<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Hightopo learn edge</title>
    <link rel="shortcut icon" href="#" type="image/x-icon">
    <script src="../lib/core/ht.js"></script>
    <style>
        html,
        body {
            padding: 0;
            margin: 0;
        }

        .main {
            margin: 0;
            padding: 0;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
        }
    </style>
    <script>
        function init() {
            var dataModel = new ht.DataModel();
            graphView = new ht.graph.GraphView(dataModel);
            view = graphView.getView();

            view.className = 'main';
            document.body.appendChild(view);
            window.addEventListener('resize', function (e) {
                graphView.invalidate();
            }, false);

            var source = new ht.Node();
            source.setName('source');
            source.setPosition(100, 70);
            dataModel.add(source);

            var target = new ht.Node();
            target.setName('target');
            target.setPosition(260, 70);
            dataModel.add(target);

            var edge = new ht.Edge();
            edge.setSource(source);
            edge.setTarget(target);
            dataModel.add(edge);

            edge = new ht.Edge(source, target);
            edge.toggle();
            dataModel.add(edge);

            edge = new ht.Edge(source, source);
            dataModel.add(edge);

            graphView.getLabel = function (data) {
                if (data instanceof ht.Edge) {
                    if (data.isEdgeGroupAgent()) {
                        return data.getEdgeGroupSize() + ' become 1';
                    }
                }
                return data.getName();
            };
        }
    </script>
</head>

<body onload="init()">

</body>

</html>